package com.article.service.impl;

import com.article.entity.ApiResult;
import com.article.entity.model.ArticleContent;
import com.article.mapper.ArticleContentMapper;
import com.article.service.ArticleContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ArticleContentServiceImpl implements ArticleContentService {

    @Autowired
    private ArticleContentMapper articleContentMapper;

    @Override
    public ApiResult addArticleContent(ArticleContent param) {
        int affected = articleContentMapper.insertSelective(param);
        if (affected > 0 ){
            return ApiResult.ok();
        }else{
            return ApiResult.fail();
        }
    }

    @Override
    public ApiResult deleteArticleContentById(ArticleContent param) {
        int affected = articleContentMapper.deleteByPrimaryKey(param.getId());
        if (affected > 0 ){
            return ApiResult.ok();
        }else{
            return ApiResult.fail();
        }
    }

    @Override
    public ApiResult updateArticleContentById(ArticleContent param) {
        int affected = articleContentMapper.updateByPrimaryKeySelective(param);
        if (affected > 0 ){
            return ApiResult.ok();
        }else{
            return ApiResult.fail();
        }
    }

}
